package com.guoxue.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.guoxue.dao.IExpertReadingDao;
import com.guoxue.domain.ExpertReadingVo;

@Repository
public class ExpertReadingDaoImpl extends BaseDaoImpl<ExpertReadingVo> implements IExpertReadingDao{

	@Override
	public void saveExpertReading(ExpertReadingVo er) {
		saveOrUpdate(er);
	}

	@Override
	public List<ExpertReadingVo> getExpertReadingList() {
		return find("From ExpertReadingVo");
	}

	@Override
	public void deleteExpertConfig(int id) {
		executeHql("DELETE FROM ExpertReadingVo e WHERE e.workId=?", new Object[] {id});
	}

	@Override
	public List<ExpertReadingVo> getExpertReadingList(String searchName) {
		return find("From ExpertReadingVo e WHERE e.bookName LIKE ? or e.workReader like ? ORDER BY e.bookName ASC ",new Object[]{"%"+searchName+"%","%"+searchName+"%"});
	}

	@Override
	public ExpertReadingVo getExpertReading(String tapeId) {
		return get("From ExpertReadingVo e WHERE e.workId = ? ", new Object[]{Integer.valueOf(tapeId)});
	}

}
